package com.arron.simplefactory.pizzastore;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class OrderPizza{
    public OrderPizza() {
        Pizza pizza;
        String orderType;
        do {
            orderType = getType();
            if (orderType.equalsIgnoreCase("greek")){
                pizza = new GreekPizza();
                pizza.setName("greek");
            } else if (orderType.equalsIgnoreCase("cheese")) {
                pizza = new CheesePizza();
                pizza.setName("cheese");
            } else if (orderType.equalsIgnoreCase("pepper")) {
                pizza = new CheesePizza();
                pizza.setName("pepper");
            } else {
                break;
            }
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }

    private String getType() {
        try {
            BufferedReader strIn = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type:");
            String str = strIn.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
